package com.atguigu.yygh.hosp.service.impl;

import com.atguigu.yygh.hosp.mapper.HospitalSetMapper;
import com.atguigu.yygh.hosp.service.HospitalSetService;
import com.atguigu.yygh.model.hosp.HospitalSet;
import com.atguigu.yygh.vo.hosp.HospitalSetQueryVo;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mysql.cj.util.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 医院设置表 服务实现类
 * </p>
 *
 * @author atguigu
 * @since 2022-11-05
 */
@Service
public class HospitalSetServiceImpl extends ServiceImpl<HospitalSetMapper, HospitalSet> implements HospitalSetService {

    @Autowired
    HospitalSetMapper hospitalSetMapper;

    @Override
    public Page<HospitalSet> selectPage(HospitalSetQueryVo hospitalSetQueryVo, Page<HospitalSet> hospitalSetPage) {
        String hoscode = hospitalSetQueryVo.getHoscode();
        String hosname = hospitalSetQueryVo.getHosname();

        //构建查询条件
        QueryWrapper<HospitalSet> wrapper = new QueryWrapper<>();
        wrapper
                .like(!StringUtils.isNullOrEmpty(hosname), "hosname", hosname)  // 模糊查询医院名称
                .eq(!StringUtils.isNullOrEmpty(hoscode), "hoscode", hospitalSetQueryVo.getHoscode());

        return hospitalSetMapper.selectPage(hospitalSetPage, wrapper);
    }
}
